import random
from room import Room


class People(object):
    room = Room()
    room.storeAnimal()

    # 敲门动作
    def knock(self, num):
        animal = self.room.getAnimal(num)
        animal.cry()

    # 喂食动作
    def feed(self, num, food):
        animal = self.room.getAnimal(num)
        animal.eat(food)

    # 获取每个房间，及动物和体重
    def getWeight(self):
        storeRoom = self.room.getStoreRoom()
        lisRoom = self.room.getLisRoom()
        for roomNum in storeRoom.keys():
            animal = self.room.getAnimal(roomNum)
            if lisRoom[roomNum-1] is 1:
                print("第"+str(roomNum)+"个房间是：羊；体重是："+str(animal.weight)+"斤")
            else:
                print("第" + str(roomNum) + "个房间是：虎；体重是：" + str(animal.weight) + "斤")

    def startGame(self):
        lis = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        num = random.choice(lis)
        print("第"+str(num)+"个房间")
        while True:
            print("请选择敲门（knock）还是喂食（feed）? k or f")
            com = input()
            if (com == 'k' or com == 'f') is not True:
                print("输入错误请重新输入！")
                continue
            else:
                break
        if com is 'k':
            self.knock(num)
        elif com is 'f':
            while True:
                print("喂老虎应该输入单词 meat，喂羊应该输入单词 grass")
                com1 = input()
                if (com1 == "meat" or com1 == "grass") is not True:
                    print("输入错误请重新输入！")
                    continue
                else:

                    break
            self.feed(num, com1)



